<?php
include_model("ModulesDao");


function callService_Modules_InstalledList($pdio, $input) {
    
    $mDao = new ModulesDao($pdio);
    return $mDao->retrieveList();
}

function callService_Modules_AllList($pdio, $input) {

    $allModules = glob(APP_PATH.'modules/*', GLOB_ONLYDIR);
    
    $mods = array();
    foreach ($allModules as $k => $fullPath) {
        $toks = explode('/',$fullPath);
        $fullPath = end($toks);
        $mods[] = $fullPath;
    }
    return $mods;
}

function callService_Modules_NotInstalledList($pdio, $input) {

    $mDao = new ModulesDao($pdio);
    $installedModules = $mDao->retrieveList();
    
    foreach ($installedModules as $v) {
        $viMods[$v['name']] = $v;
    }    
    
    $allModules = glob(APP_PATH.'modules/*', GLOB_ONLYDIR);
    
    $niMods = array();
    foreach ($allModules as $k => $fullPath) {
        $toks = explode('/',$fullPath);
        $fullPath = end($toks);
        if (!isset($viMods[$fullPath])) {
            $niMods[] = $fullPath;
        }
    }
    return $niMods;
}

function callService_Modules_Install($pdio, $input)  {
	
}


/**
 * 
 *     	"Modules_InstalledList" => SERVICES_PATH.'Modules.php',
        "Modules_NotInstalledList" => SERVICES_PATH.'Modules.php',
        "Modules_AllList" => SERVICES_PATH.'Modules.php',
        "Modules_IsInstalled" => SERVICES_PATH.'Modules.php',
        "Modules_Install" => SERVICES_PATH.'Modules.php', 
        "Modules_Uninstall" => SERVICES_PATH.'Modules.php',                    
            
 */